<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Guide to the DPeye</title>
</head>
<body>

<h1>Command-line style map creation </h1>

<h3>How to create a ps map for the DPjudge from a bitmap image using a small Tcl-script</h3>
<p>
We can divide the task at hand into 3 phases, which can be characterized with the following 3 L's: <b>Line out</b>, <b>Locate</b>, <b>Layout</b>.
<ul>
	<li><a href="#LineOut">Phase 1: Line out</a> is the process of converting a blank map from a pixel based bitmap image format to the vector based PostScript and PDF formats, 
	an action more commonly known as tracing. </li>
	<li><a href="#Locate">Phase 2: Locate</a> means assigning coordinates for all the objects on the map, such as units, SCs, etc. </li>
	<li><a href="#Layout">Phase 3: Layout</a> concerns itself with providing space for the various text portions on the page, 
	such as the order and ownership sections. </li>
</ul>
We'll create a small script which will grow in size as we proceed through the phases. 
But before that, let's start with the installation. 
</p>
<h3>What's in a name?</h3>
<p>
The DPeye is a companion to the DPjudge. The "eye" in DPeye refers to a private eye (a detective), 
the indispensable partner in many lawsuits, pouring over every detail to present his
findings to the judge or his clients (the powers in Dip speech). The analogy seems to
hold for a tool that aims to create variant maps, giving players an up-to-date view of
the action throughout the game.
</p>
<a name="#Installation"/><h2>Installation</h2>
<p>
In this guide I will assume that you are working on Windows. If on other systems, adapt
as necessary.
</p><p>
Install DPeye. The DPeye is at its core a single application for creating maps, but
offers also a number of tools, some of which will be introduced in this guide, indicated by
an <b>[Eye mark]</b> label at the start of the paragraph. 
</p><p>
Create a subfolder for your project in the variants folder, which will serve as your work folder.
Copy in there the bitmap file (or image file) which you want to convert. 
</p><p>
<a name="Paint"/> We'll do all kinds of manipulations on
this file, for which you can use any sort of bitmap editor, but for the sake of 
simplicity I'll assume that you are using Paint, the standard, though somewhat barebones graphics painting program for Windows.
You may already be familiar with this product, which is otherwise pretty straightforward to use.
Comments on particular Paint features in this guide will be preceded by <b>[Paint tip]</b>.  
</p><p>
<b>[Paint tip]</b> To start Paint, click the Start button and look under Programs -> Accessories, 
or simply right-click on your bitmap file and select Edit.
</p><p>
<a name="ActiveTcl"/> You will need to install a Tcl interpreter. I recommend ActiveState's 
<a href="http://www.activestate.com/Products/activetcl/index.mhtml">ActiveTcl</a>. 
Familiarity with Tcl is not a must in order to use this program. The little that you
need to know will be marked in this guide with <b>[Tcl info]</b>.
</p><p>
<a name="AutoTrace"/> This program uses a free software tool called <a href="http://autotrace.sourceforge.net">AutoTrace</a> 
for converting bitmaps to eps-files (Encapsulated PostScript). There are other trace 
software that do a better job, such as CorelTrace for CorelDraw, but they are expensive, 
hence the choice. If you are lucky enough to own a better tracer, contact me. Particular
details on AutoTrace in this guide will be marked with <b>[Trace point]</b>. 
</p><p>
Download and install AutoTrace under "C:\Program Files\AutoTrace". If installed elsewhere, 
you will need to specify eTraceDir in the script-file that you will make (see further). 
</p><p>
<b>[Trace point]</b> A further advantage of AutoTrace is that it can be executed from the command
line, allowing incorporation into scripts such as here. A great convenience since you will be
using this program a lot.
</p><p>
<a name="Ghostscript"/> For viewing the ps (PostScript) files that you will create and constantly modify, I 
recommend <a href="http://pages.cs.wisc.edu/~ghost/">Ghostscript</a> and its viewer GSview. You will 
also need Ghostscript to turn ps into pdf, useful if you want other people to see your 
work in progress without requiring them to install any additional software, as Acrobat 
Reader for pdf-files is pretty standard now on every system worldwide. Plus you probably 
want to check if your final product looks as well in ps as in pdf, as the DPjudge offers 
both formats. Tips about PostScript and PDF will be preceded by <b>[PS note]</b>.
</p><p>
These applications as well are free to download. After installing them, add the 
bin folder for Ghostscript (akin to "C:\Program Files\gs\gs8.63\bin") to your system path 
(Start button -> Control Panel -> (Performance and Maintenance ->) System -> Details tab 
-> Environment Variables button; select Path, click edit and prepend the above paths, 
separated by semicolons). Check also that the path to the Tcl bin folder is there 
("C:\Program Files\Tcl\bin", but this too can vary). 
</p>
<a name="#LineOut"/><h2>Phase 1: Line out</h2>
<p>
With all these tools installed, it's time to start the real work. Open your bitmap in 
Paint and, if not already so, save it as a 16 or 256 color .bmp file. Keep the original
file as reference. Strip out everything until you get a blank map: No text, no legends,
no SCs, no arrows, no decorations, no background color, just borders. 
You can make another file which has the SCs on it for later use. If there's a frame 
around the map, remove it and shrink the size of the image to the part within the frame, an operation
called cropping. Note that I assume here that the map frame is rectangular. For other shapes, contact 
me. 
</p><p>
<b>[Paint tip]</b> Since Paint does not seem to have a crop feature, you can do the following. 
Push Select (the button with the dashed line rectangle on it) and select the whole area inside the frame by
dragging the rectangle from the top left corner to the bottom right corner within the frame. Release the
mouse button, click inside the thus selected area and move it to the top left 
corner of the image. Next change the canvas size using one of the Image menu commands or by pressing 
Ctrl+E. 
</p><p>
<a name="FilledPlane"/><b>[Special case]</b> If there's no border on the coast, make a separate file that only has the land in one 
color and the sea in another color on it. The original file with all the internal borders 
on it can continue to include the land mass as a kind of background, provided it's in a 
different color than any of the borders at any point in time.
</p><p>
Color the borders. Use different colors for the coastline, borders between sea spaces,
lake borders, borders around impassable areas, national borders and provincial borders, if 
present. Try to limit your choice of color to the primary 16 colors that Paint uses. These are in order:
</p><p align="center">
<table border=1>
	<tr><td align="center" bgcolor="black"><font color="white">black</font></td><td align="center" bgcolor="gray"><font color="white">grey</font></td><td align="center" bgcolor="maroon"><font color="white">maroon</font></td><td align="center" bgcolor="olive"><font color="white">olive</font></td><td align="center" bgcolor="green"><font color="white">green</font></td><td align="center" bgcolor="teal"><font color="white">teal</font></td><td align="center" bgcolor="navy"><font color="white">navy</font></td><td align="center" bgcolor="purple"><font color="white">purple</font></td></tr>
	<tr><td align="center" bgcolor="white"><font color="black">white</font></td><td align="center" bgcolor="lightgrey"><font color="black">lightgrey</font></td><td align="center" bgcolor="red"><font color="black">red</color></td><td align="center" bgcolor="yellow"><font color="black">yellow</font></td><td align="center" bgcolor="lime"><font color="black">lime</font></td><td align="center" bgcolor="cyan"><font color="black">cyan</font></td><td align="center" bgcolor="blue"><font color="black">blue</font></td><td align="center" bgcolor="magenta"><font color="black">magenta</font></td></tr>
</table>
</p><p>
Hint: For this step, limit your choice further to the top row colors only.
</p><p>
<a name="BrokenBorders" /> Things to watch out for. Borders should be unbroken and link up to each other all over the
map. Borders that stretch out to the edge of the map should touch the edge. Lines can be 
of any thickness and need not be of constant thickness. The thinnest line is a single 
pixel wide. Unbroken means the pixels that make up the line are adjacent to each other 
either horizontally, vertically or diagonally. Borders that define planes, such as 
continental borders, island borders, lake borders, borders around impassable areas, are
called contours and should consist of a single, unbroken 
line that has either no end points or whose end points are on the edge of the map. 
Contours should also not touch any other contour. If they do, either redraw the borders 
so they don't touch any longer or use a different color for each contour. The same care 
must be taken with other borders that touch each other in other places than where they 
connect. 
</p><p>
<a name="NeighbourPlanes"/><b>[Special case]</b> If an impassable area borders, rather than being fully contained inside another plane,
split into two files and color the joint border in a different color in either file. 
Better still, since there's no guarantee that the same border will be rendered identically if it's
a part of two different figures, draw a different border in one file, which may consist of only
one or a few straight lines and is fully contained within the second plane, so that the first 
plane partly covers the second plane. Then when tracing
the different files, take care that the second one is rendered on top of the first one. See also the
<a href="#Youngstown">youngstown example</a>.
</p><p>
<b>[Paint tip]</b> Coloring borders will make you very familiar with Paint's pencil and fill (the little paint can) buttons.
Use the pencil to make corrections to the map and to mark cut off lines for borders. Use
the fill button to fill the thus cut off border line in a different color. Unfortunately
Paint does not fill across diagonal connections. This means that for 1 pixel wide lines (a
very common occurrence in many maps), you need to point and click each line piece separately,
requiring time and concentration. You will occasionally misclick and fill the whole area next to 
the border line. Stay cool, with the undo (Ctrl+Z) and redo (Ctrl+Y) commands (also available in the edit menu) 
you can undo upto 3 operations. As for time consumption, cherish the satisfaction found in 
the small progress you'll be making and keep the end goal in mind.
</p>
<h3>First conversion</h3>
<p>
Now you're ready to do a first conversion. Create an empty Tcl-file in your project folder.
I recommend giving it the name of the variant you're making. In it, we'll start by defining 
a few constants:
<pre>
	set eWorkDir [pwd]
	set eDPeyeDir "../.."
</pre>
</p><p><b>[Tcl info]</b>
In Tcl-scripts, you can use both forward and backward slashes as directory separators. 
Forward slashes are recommended, since the backward slash is Tcl's escape character inside
strings, and thus needs to be doubled up if used within a quoted string.
</p><p>
Other constants that you can set, if needed, are eTraceDir (default: 
"C:/Program Files/AutoTrace") and eCacheDir (default: "C:/Windows/Temp"). 
</p><p>
After setting these constants, let's load the program, located in the core subfolder.
<pre>
	source "../../core/autocompose.tcl"
</pre><p>
Now for the create command. This command consists of the command name itself
followed by a list of options, which are added in any order by giving the option 
name followed by the value. The fixed parameters are:
<ul>
	<li>the name of the resulting ps file</li>
	<li>the name of the DPjudge .map file (if available, otherwise "")</li>
</ul>
</p><p>
The options are too numerous to sum up now. We'll cover them when their topic comes up. 
Here's our first create command:
<pre>
	create {
		outputFile ambition.ps
		title "Ambition & Empire, designed by Jeff S. Kase and Baron M. Powell"
		creator "Mario Huys (woelpad@yahoo.com)"
		images {
			all ambition.bmp
		}
		borders {
			seaBorders {{all teal} InternalBorder}
			land {{all black} CoastalBorder LandBrown}
			internalBorders {{all green} InternalBorder}
			borders {{all maroon} NationalBorder}
			mountain {{all grey} NationalBorder MountainGrey}
			lake {{all navy} CoastalBorder SeaBlue}
		}
	}
</pre>
</p><p>
In this example we're trying to create the A&E variant. Our output file is 
called ambition.ps. Adapt file names and other parameters such as colors to your own creation. 
If no output file is specified, the create command will just go through the motions without actually creating a file. 
</p><p><b>[Tcl info]</b>
Note how this command is broken up
across several lines in typical Tcl style, with an opening brace at the end of the first 
line, matched by a closing brace at the end of the script and repeated internally everywhere lists
are used. Lists may also be written on one line instead of split across multiple lines and freely
intermixed, as is shown in the borders option, where every line is composed of a name and a parameter list and every 
first parameter of that list is in itself a list (e.g. {all teal}).
The initial tabs are optional but enhance readability. 
</p><p>
This command specifies four options. The first two identify the map and the creator (presumably you).
This information will appear inside the PostScript at the start of the file in the form of
structured comments, which various tools can display, and which will even be passed on to the 
PDF file (see <a href="#ps2pdf">ps to pdf conversion</a>; after converting, open the Properties dialog under the File menu in Acrobat to verify). 
As with every other option, these can be omitted if not wanted.
</p><p>
Then come two lists. The first of these, images, lists all the bitmaps that 
are needed for the conversion. At this point there's only one, which we identified here 
with "all", followed by the name of the bitmap file. The second specifies the several 
types of borders. Each border gets a name (which you are free to choose, provided it's 
unique); a specification consisting of the image identifier ("all") and the color used 
within that image for this type of border; a stroke command (choices are: 
"InternalBorder", "CoastalBorder", "NationalBorder", the generic "Border", or "" meaning 
no stroke); and optionally a fill color (LandBrown, SeaBlue, MountainGrey, IceGrey a.o.; see available PS colors later). 
</p><p>
<b>[PS note]</b> Stroking and 
filling are PostScript terms. The first applies to lines: line thickness, line color, etc. are
all stroke parameters. The second to planes and mostly deals with the color 
used (which can be as simple as a straight color or as complicated as a shade).
</p><p><b>[Tcl info]</b>
Notice how empty (non-specified) elements at the end of a list can be omitted. The
internalBorders border does not have a fill color and therefore has one parameter less
than e.g. the land border.
</p><p>
<a name="RenderingOrder"/>Order (sometimes) matters. The order in which the borders are listed is important in some cases, helpful in others, as it's
the same order in which they will be rendered, bottom to top. The mountains and lakes, as well as the
internal and national borders, need to be listed after the land section, otherwise they will not be visible.
By default the sea is painted first, unless you change the backGroundColor option (default: SeaBlue; setting to "" possible).
Painting the sea borders next, then the land, gives you the freedom to extend the sea borders beyond the shores,
as the subsequent land mass will cover up any litter. This is especially useful for very short borders that e.g. run between
two islands. Extending and connecting them with other sea borders under the islands allows for a better rendering. 
The same can be said of internal and national borders which can best be drawn before lakes and mountains.
</p><p>
The script is ready. Save it as a .tcl file. To run this script, open a Command Prompt, which you can find
under Start Button -> Programs -> Accessories, cd to your project directory and type
<pre>
	tclsh ambition.tcl
</pre>
</p><p>
It ran to completion, did it? Chances are it also spawned a lot of text. The first line 
should inform you that the .bmp file was traced. The next line informs about discarded loose
curves, followed by starting and ending coordinates for each discarded curve. These are contours 
that unfortunately did not meet the conditions outlined <a href="#BrokenBorders">before</a>. 
</p><p>
<b>[Paint tip]</b> To locate these trouble
borders, open the .bmp file again in Paint. You will notice that when you move the cursor across
the image, two numbers in the bottom right of the window change along. These are the coordinates
which you need to match to an endpoint of each of the loose curves (give or take a few pixels). 

</p><p> Find out and correct (edit) what was wrong. After correction, rerun the script. When all information about
loose curves has gone, only then it's time to congratulate yourself.
At this point a file ambition.ps (or whatever output file name you chose) will be created.
Open it in your PostScript viewer (GSview). Isn't it amazing? 
</p>
<a name="Youngstown"/><h3>A second example</h3>
<p>
Here's a slightly more complicated example.
<pre>
	create {
		outputFile youngstown.ps
		title Youngstown
		creator "Mario Huys (woelpad@yahoo.com)"
		images {
			continent {continent.bmp 0 1}
			ice {ice.bmp 0 1}
		}
		borders {
			seaBorders {{continent teal} InternalBorder}
			ice {{ice grey} CoastalBorder {IceGrey 1}}
			land {{continent black} CoastalBorder LandBrown}
			internalBorders {{continent green} InternalBorder}
			borders {{continent maroon} NationalBorder}
			mountain {{continent grey} NationalBorder MountainGrey}
			lake {{continent navy} CoastalBorder SeaBlue}
		}
	}
</pre>
</p><p><b>[Tcl info]</b>
Compare this title option with the title option in the previous example and 
notice how the use of quotes around names is optional, unless the name contains spaces,
tabs or newlines (the so-called whitespace characters) or
other special characters, some of which need to be escaped, such as
the backslash and the double quote, and in some cases (though not in the scripts as described in this guide) 
curly and square braces, the $-sign, etc. Consult the excellent ActiveTcl manual for 
a deeper explanation. 
</p><p>
In this example, the border of the arctic ice cap, which is impassable, but touches the continent,
was colored in a different file, ice.bmp, which has the same image width and height as the original
file, here named continent.bmp. Both the continent and ice images have two
additional numbers after the file name, making it necessary to enclose the lot in curly brackets.
</p><p><b>[Tcl info]</b>
As with quoting, a list consisting of a single element does not need to be surrounded with
curly brackets. Hence in the first example the file name, being the only parameter, was unbracketed. 
Compare also the fill color parameter for the land border (no brackets) with that of the ice border (brackets).  
</p><p>
The first one of these numbers tells whether the image needs to trace the 
fill regions rather than the borders (0 or 1, 0 by default). Set this to 1 when tracing filled planes
such as those described in the first <a href="#FilledPlane"><b>Special case</b></a>.
</p><p>
The second additional parameter is an integer number upwards from
0 (default), altering the quality of the trace: The higher this number, the curvier the
result. Whereas 0 has a tendency to show lots of straight lines and sharp angles, a high number
can result in very rounded, but almost unrecognizable shapes. It pays off to experiment with this
parameter a few times before moving on.
</p><p><b>[Trace point]</b> AutoTrace calls this feature "filter iterations". On every iteration
the curves will become smoother and smoother, presumably by gradually approximating the picture
in the previous iteration with less and less curves. It's probably not worthwhile to go beyond 5 iterations,
as your map will be completely smoothed out by that time.
</p><p>
The ice border parameter list has for its last parameter a list of two parameters. The first
one of these is the familiar fill color. The second one specifies whether the top left corner
of the image is part of the plane (0 or 1, default 0). For planes that touch the edge, setting
this parameter wrongly would end up coloring everything outside the plane instead of inside.
</p><p><b>[Remark]</b>
In the actual youngstown map, available on the DPjudge, the ice cap is located in the top center, away from
any corner, and as such does not have its top left corner bit set. A small contortion of the truth for the sake
of demonstration. The ice.bmp file however exists and lets the ice plane extend under Russia, as was recommended
in a previous <b><a href="#NeighbourPlanes">Special case</a></b>. Note how the ice border parameter list is 
listed before the land border parameter list, ensuring that the land mass is rendered on top of the ice plane 
covering up the part where they overlap.
</p>
<h3>Improving the map</h3>
<p>
After the excitement of having created and viewed your first ps file dies out,
you'll probably start to notice some irregularities. Borders that don't connect,
others that extend beyond where they are supposed to go, small islands which look like
sharp-angled triangles (which they are), even smaller islands that are just stripes in
a sea of blue, ... Isn't there a better tracer? Yes, there are, but they are beyond our
budget, so let's go with what we have. BTW, if you have tried out all the quality levels
and still find that the best one does not do justice to the original bitmap image,
rest assured; provided the original map was good and you take care of the aforementioned 
problems, the general public will love your product.
</p><p>
<a name="ps2pdf"/> <b>[Eye mark]</b> At this point, you might already want to let your contacts show the progress you are making
to get a few well deserved gasps and some valuable feedback.
Even if they have a PS viewer, as you can't be sure on which machine they will be reading 
their e-mail, it's best to convert it to PDF first. I assume you have Ghostscript installed 
and the path to the bin folder added to your system path as described in <a href="#Ghostscript">Installation</a>.
Switch to your command prompt again and execute the following:
<pre>
	tclsh ../../tools/ps2pdf.tcl ambition.ps ambition.pdf
</pre>
This will create ambition.pdf in your project folder. 
</p><p><b>[PS note]</b> If you open this file in Acrobat, you might notice
some differences with GSview. The frame around the image seems to have only two bands instead of three, a straight
horizontal line might seem a bit thick, etc. Zooming in should convince you that there's nothing
wrong; Acrobat and GSview simply have different conventions on how to render thin lines.
</p><p>
Let's start with the tiny islands and lakes (if any) that dither your map. The keywords are: Reduce
and reshape. Throw away those that don't matter, merge others together, enlarge the remaining.
Also look out for shapes that did come out ok. The same 6-pixel island contour will be rendered
differently if standing upright or on its side. Which one looks best? Slightly bigger islands,
depending on their orientation, end up either as vicious edges or more compact shapes. Pick out
the ones you like and copy them to replace the ones you don't (the Select button will be of some
help there).
</p><p>
Connecting the borders. Let's start by adding one option to our create command, testBorder (default: 0), and
give it the value 1.
<pre>
	create {
		...
		testBorder 1
	}
</pre>
</p><p>
<b>[Tcl note]</b> Tcl is case sensitive, and as such it does you no good to try
to write testBorder as testborder, TestBorder or anything else, as in that 
case it will simply be ignored. 
</p><p>
<b>[PS note]</b> Run this script and switch again to GSview. You will notice
that GSview automatically detects that the PS file has changed and immediately
reloads it. There's thus no need for pressing F5 or anything. Sometimes you will
switch to GSview too early, while the script is still running and thus before the 
ps-file is saved. In that case, switch back to the command prompt, check that the
script completed and switch to GSview again to initiate the reload.
</p><p>
What this option does is turn all borders into unbroken lines of the same
thickness. This will make it much easier to assess how much correction is
needed. You can actually change the testBorder value to any positive real (or floating point) 
number to change the line thickness; e.g. 2 will make all borders twice as thick, 0.5 (or .5 for short)
half as thick. Don't forget to remove this option or set it to 0 after all corrections
are done. 
</p><p>
<b>[PS note]</b> We'll also need to zoom in. There are zoom buttons on GSview's toolbar,
but they only zoom in little by little. We want to zoom in to twice the current level,
requiring frequent clicking, now as well as when we zoom back out to the original resolution. 
Better is to click Display Settings in GSview's Media menu. The first parameter, Resolution, 
is the one we'd like to change. The initial setting is 96 dpi (dots per inch). Change it to 200 or higher and click Ok.
Depending on how high you set it, it might take a while before the picture starts showing,
but once it does, moving around is pretty smooth. 
</p><p>
The first thing to tackle are the non-contour borders that touch the edge. Unlike the 
contours, these are not automatically pulled towards the edge and thus there might be
a little gap between their endpoint and the image frame. There are two solutions to this:
enlarge the frame or move the frame inwards. This can be done by altering 
$FrameThickness (default: 4) and $FrameOverlap (default: 0). $FrameOverlap determines
how far inwards the frame is placed; it must be between 0 (no overlap) and $FrameThickness
(complete overlap). That means that if you change $FrameOverlap to 2 without changing
$FrameThickness, the frame will move halfway inwards.
<pre>
	create {
		...
		$FrameOverlap 2
	}
</pre>
</p><p>
<b>[Tcl Info]</b> In Tcl the "$" at the start of a name usually denote variables.
For this program however, the "$" parameters are not Tcl variables, but a kind of
meta PostScript variables, that are replaced with real values when outputting the
ps-file. The file dpmapitacts.ps in the core subfolder has a whole page of
such PS variables at the start of the file, representing default values, each of
which you can change similarly to $FrameOverlap, i.e. by specifying a new value
inside the create command.
</p><p>
Note: It's possible to remove the frame completely. Add the option drawFrame (default: 1) to the script and
give it the value 0. You certainly want to do this if your map is not a rectangle.
</p><p>
Correcting border connection points requires altering the borders in the image file.
Sometimes a single pixel extra or less will suffice, sometimes a long stretch needs to
be added or corrected. Since in many cases this entails using the same pixels for different
border lines, you will have to create one or more copies of the image file, keeping the 
original file for the contour lines and the extra files for extracting the internal borders
(including national and sea borders). 
</p><p>
For borders whose endpoints connect with a contour line, a single copy can
suffice. This does not include provincial borders ending in national borders, for
which a second copy will be necessary. Take the case of a sea border connecting
with the continent, but leaving a small gap at the end. Often simply coloring the pixel
where the internal border touches the contour, in the color of the internal border, 
is sufficient to remove the gap. Other times you will need to extend beyond the contour,
or remove a few pixels, or even bend the border completely to get the desired effect. 
In this case, the ends justify the means, so don't hesitate too much to make some radical
changes from time to time.
</p><p>
If you've been paying attention, you'll realize that with the right <a href="#RenderingOrder">order</a>,
you won't have to worry too much about the correct length for sea borders ending on land
coasts, or provincial or national borders touching lakes or mountains: Just make them long
enough and they'll be cut off the way you want it. Also make use of the advice given there concerning 
connecting short lines under islands, lakes and mountains.
</p><p>
For provincial or national borders ending
on the coast, you will need to be more careful. Strive to let the line end just on the contour
line, but if they fall a little bit short or cut through a bit too far, so be it. On normal
resolution, these small differences will be hardly noticeable. This is even more so in the case
of (thin dashed) provincial borders ending in (thicker) national borders.
</p><p>
Note: In relation with bending borders, it's good to strive for borders to meet at 
a perpendicular angle. These are the easiest to get right as you have the full line
thickness to blend into. Under a slanted angle, your margin of error becomes much smaller.
</p><p>
After making these corrections, running and rerunning many times to get it all right,
your script might look like this:
<pre>
	create {
		outputFile ambition.ps
		title "Ambition & Empire, designed by Jeff S. Kase and Baron M. Powell"
		creator "Mario Huys (woelpad@yahoo.com)"
		images {
			contour ambition.bmp
			borders1 borders1.bmp
			borders2 borders2.bmp
		}
		borders {
			seaBorders {{borders1 teal} InternalBorder}
			land {{contour black} CoastalBorder LandBrown}
			internalBorders {{borders2 green} InternalBorder}
			borders {{borders1 maroon} NationalBorder}
			mountain {{contour grey} NationalBorder MountainGrey}
			lake {{contour navy} CoastalBorder SeaBlue}
		}
		testBorder 1
		$FrameOverlap 2 
	}
</pre>
</p><p>
Next on the list is fixing borders of the same type. Color one border in a different
color. If you have followed the hint given at the start, you can now use for that
second color the color on the second row, right under the first color. E.g. if you
chose maroon for the national borders, choose red. 
</p><p>
How far do you need to color this border? That depends on the situation. In general
at least up to the next connection point. Stopping halfway may sometimes be good 
enough though. Just make sure that the line is not too short.
</p><p>
Color the same border piece in both border files, only coloring the pixels that define the
joint points (and any necessary corrections) in a different color in each file. E.g. if you
originally chose maroon in the first borders file to color all national borders, the natural
choice is to continue with maroon in this file for the joint points, and red in the other
borders file. If you are careful enough, but this requires some puzzling, this second borders 
file may be the one used to fix the provincial borders. Otherwise a third borders file, 
starting as a copy of the first borders file, may be a solution. Likewise for the sea and 
provincial borders. Mind though that the more files to deal with, the more time the tracing will take.
</p><p>
To combine and piece these borders back together, you can simply extend the selections list (the first
parameter of each border specification), to include the thus separated borders. Our final script for
phase 1 may now look like this: 
<pre>
	create {
		outputFile ambition.ps
		title "Ambition & Empire, designed by Jeff S. Kase and Baron M. Powell"
		creator "Mario Huys (woelpad@yahoo.com)"
		images {
			contour ambition.bmp
			borders1 borders1.bmp
			borders2 borders2.bmp
		}
		borders {
			seaBorders {{borders1 teal borders2 cyan} InternalBorder}
			land {{contour black} CoastalBorder LandBrown}
			internalBorders {{borders2 green borders1 lime} InternalBorder}
			borders {{borders1 maroon borders2 red} NationalBorder}
			mountain {{contour grey} NationalBorder MountainGrey}
			lake {{contour navy} CoastalBorder SeaBlue}
		}
		testBorder 1
		$FrameOverlap 2 
	}
</pre>
When finally satisfied, remove the testBorder option and admire the result.
</p>
<h3>A different approach</h3>
<p>
Youngstown. Remove instead of recolor, allowing to use the same image color in both border files. Canal borders.
</p>
<a name="#Locate"/><h2>Phase 2: Locate</h2>
<h3>Difference with map files</h3>
<p>
Note that the land portion of a multicoastal territory is specified as a COAST in a DPjudge map file, but should
be added to the lands in the locations section. That's simply because the only unit that can be stationed there is
an army.
</p>
<h3>New border definition</h3>
<p>
Borders revisited. The new format is:
<pre>
	borders {
		borderName {{[[imageNames imageColors]|[shapeNames {}]|[bbox imageNames]]+} {fillColor fillLevel summarize} [borderType borderParams]*}
	}
</pre>
</p><p>
The fill level determines how to mix in fills and strokes.
</p><p>
You can render strokes on top of fills (values 0 or 1), or underneath fills (values 2 or 3).
In the latter case only the outer half of the strokes are rendered, but this is compensated by an automatic doubling of the stroke width. 
</p><p>
The same doubling happens when using InnerHalfBorder or OuterHalfBorder as the border type, though they do not combine. 
It does not make much sense either to use fill level 2 or 3 in combination with InnerHalfBorder or OuterHalfBorder, as either the whole border will be invisible (Inner), 
or the visible part is exactly the same (Outer), but the rendering operation, when compared to a simple Border, is much more expensive.
</p><p>
You can do this on a path by path basis (values 1 or 2), or on the whole (values 0 and 3), in which case all fills/strokes are rendered first before rendering the other part.
</p><p>
The default value is 1.
</p><p>
A border type can either have a single set of paramaters (such as for Border, NationalBorder, InnerHalfBorder, ...),
or more than one set of parameters (such as for FrameBorder, which consists of an inner and an outer border).
</p><p>
Strokes are rendered bottom to top.
</p><p>
One special border type is Interior, which corresponds to a fill operator and consequently only takes a color as parameter. It will not however do any automatic stroke width doubling of underlying strokes.
</p><p>
The frame is defined in exactly the same way as a single border, except that the fill level is always 0, as this specifies the background color.
The default frame path (frame selection) is bbox, the bounding box of every image used in the border section.
</p>
<h3>Shapes</h3>
<p>
Can either consist of a single (closed) path, or a series of figures.
<pre>
	locationTypes {
		ShapePoints {number 1}
	}
	locations {
		locationName {{[imageNames imageColors] ShapePoints operator numberColor}
	}
	shapes {
		shapeName {[locationName {[shapeOperator {locationPoints}]+}]+}
	}
</pre>
</p><p>
Figures require a pair of points to define one figure, but more than one pair can be listed. 
As long as the number of points is even, no error will occur.
</p><p>
Figure operators are:
<ul>
<li>
square: 
Given two opposite corner points, constructs a square between them. 
Can be rotated.
</li><li>
rectangle or rect: 
Given two opposite corner points, constructs a rectangle between them. 
Always upright.
</li><li>
circle: 
Given two diametrically opposite points, constructs a circle going through them.
</li><li>
ellipse: 
Given two points, constructs an ellipse whereby the first point denotes the leftmost or rightmost position, and the second point the topmost or bottommost position. 
Always upright.
Warns if the two points are on the same vertical or horizontal and draws a line of double their distance in that case.
</li>
</ul>
</p><p>
A path is always a single path, but can consist of more than one operator, each specifying a number of successive segments.
To close a path, the last location point in the series must exactly match the first one, and must have the same location name.
Each operator takes between one and three parameters, but more than one set can be listed, allowing for more than one successive segment of the same type.
Furthermore they can have one point extra to add a straight line either to the next path segment or to end or close the whole path.
The first point of the first operator is taken as the starting point and does not count toward the first set.
</p><p>
Path operators are:
<ul>
<li>
line or l:
Requires one point per segment.
Constructs lines between each successive point.
</li><li>
curve or c:
Requires three points per segment.
Constructs Bezier curves, with the first and second point serving as control points.
</li><li>
arc or a:
Requires two points per segment.
Constructs circular arcs from the last point of the previous segment to the second point while going through the first point.
If the three points are colinear (meaning you can draw a straight line through them), a warning is given and a line segment to the first and then the second points are added.
</li><li>
oval:
Requires three points per segment.
Constructs elliptical arcs from the last point of the previous segment to the third point, with the first and second points defining the ellipse in the same way as for the ellipse operator.
The first and second point can't be on the same horizontal or vertical.
</li>
</ul>
</p>
<a name="#Layout"/><h2>Phase 3: Layout</h2>
</body>
</html>